using AiQiuQuan.Sport.Model.Models;
using AiQiuQuan.Sport.Core;
using AiQiuQuan.Sport.WebApi.Services;
using Microsoft.AspNetCore.Mvc;

namespace AiQiuQuan.Sport.WebApi.Controllers
{
    /// <summary>
    /// 俱乐部管理
    /// </summary>
    public class ClubController : ApiController
    {
        private readonly IClubService _clubService;

        /// <summary>
        /// 俱乐部管理
        /// </summary>
        public ClubController(
            IClubService clubService
            )
        {
            _clubService = clubService;
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="id">俱乐部ID</param>
        [HttpGet("get")]
        public async Task<UnaryResult<ClubDto>> GetAsync(Guid id)
        {
            var result = await _clubService.GetAsync(id);
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 新增
        /// </summary>
        [HttpPost("add")]
        public async Task<UnaryResult> AddAsync(ClubAddDto model)
        {
            var result = await _clubService.AddAsync(model);
            return result;
        }

        /// <summary>
        /// 修改
        /// </summary>
        [HttpPost("update")]
        public async Task<UnaryResult> UpdateAsync(ClubUpdateDto model)
        {
            var result = await _clubService.UpdateAsync(model);
            return result;
        }

        /// <summary>
        /// 删除
        /// </summary>
        [HttpGet("delete")]
        public async Task<UnaryResult> DeleteAsync(Guid id)
        {
            var result = await _clubService.DeleteAsync(id);
            return result;
        }

        /// <summary>
        /// 俱乐部活动新增
        /// </summary>
        [HttpPost("add_activity")]
        public async Task<UnaryResult> AddActivityAsync(ClubActivityAddDto model)
        {
            var result = await _clubService.AddActivityAsync(model);
            return result;
        }

        /// <summary>
        /// 俱乐部活动分页列表
        /// </summary>
        [HttpPost("pagelist_activity")]
        public async Task<UnaryResult<PageResult<ClubActivityDto>>> GetClubActivityPageListAsync(ClubActivityPageRequestDto request)
        {
            var result = await _clubService.GetClubActivityPageListAsync(request);
            return UnaryResult.Succeed(result);
        }
    }
}
